<template>
  <div class="ei_dialog">
    <el-dialog
      title="审核"
      :close-on-click-modal="false"
      :visible.sync="addorUpdateVisible"
      v-if="addorUpdateVisible"
      @close="addorUpdateVisible = false"
      width="40%"
    >
      <el-form
        :model="dataForm"
        ref="dataForm"
        @keyup.enter.native="dataFormSubmit()"
        label-width="230px"
        class="demo-ruleForm"
      >
        <el-form-item label="接入方场景名称:" prop="sceneName">
          <el-input
            v-model="dataForm.sceneName"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item label="接入方厂家名称" prop="manufactorName">
          <el-input
            v-model="dataForm.manufactorName"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item label="接入方IP地址" prop="manufactorIp">
          <el-input
            v-model="dataForm.manufactorIp"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item label="接入方用途" prop="manufactorUse">
          <el-input
            type="textarea"
            :rows="2"
            v-model="dataForm.manufactorUse"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item label="接入方系统" prop="manufactorSystem">
          <el-input
            v-model="dataForm.manufactorSystem"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item
          label="局方负责人（主数据工号+姓名）"
          prop="officialPeople"
        >
          <el-input
            v-model="dataForm.officialPeople"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item label="局方部门" prop="manufactorDept">
          <el-input
            v-model="dataForm.manufactorDept"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item
          label="厂家负责人（主数据工号+姓名）"
          prop="manufactorPeople"
        >
          <el-input
            v-model="dataForm.manufactorPeople"
            placeholder="请输入"
            style="width: 300px"
            clearable
            disabled
          ></el-input>
        </el-form-item>
        <el-form-item label="接入方APIKEY" prop="manufactorApikey" v-if='dataForm.examineStatus === 3'>
          <el-input
            v-model="dataForm.manufactorApikey"
            placeholder="请输入"
            style="width: 300px"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="remail">
          <el-input
            type="textarea"
            :rows="2"
            v-model="dataForm.remail"
            placeholder="请输入"
            style="width: 300px"
            clearable
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div style="width: 100%; text-align: right">
          <el-button type="primary" @click="handleThrough(4)" v-if='dataForm.examineStatus === 3'
            >提交</el-button
          >
          <el-button type="primary" @click="handleThrough(3)" v-if='dataForm.examineStatus === 1'>通过</el-button>
          <el-button type="info" @click="handleThrough(2)" v-if='dataForm.examineStatus === 1'>不通过</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      addorUpdateVisible: false,
      dataForm: {
        id: 0,
        modelName: "",
        sceneName: "", //接入方场景名称
        manufactorName: "", //接入方厂家名称
        manufactorIp: "", //接入方IP地址
        manufactorUse: "", //接入方用途
        manufactorSystem: "", //接入方系统
        officialPeople: "", //局方负责人（主数据工号+姓名）
        manufactorDept: "", //局方部门
        manufactorPeople: "", //厂家负责人（主数据工号+姓名）
        manufactorApikey: "", //接入方APIKEY
        remail: "", //备注
        examineStatus: null, //状态
      },
    };
  },
  watch: {},
  activated() {},
  created() {},
  methods: {
    init(data) {
      this.addorUpdateVisible = true;
      this.dataForm.id = data || 0;
      if (this.dataForm.id === 0) {
        //增加
        console.log("新增");
      } else {
        console.log("修改");
        let obj = JSON.parse(JSON.stringify(data)); //深拷贝,拷贝的是对象
        this.dataForm.sceneName = obj.sceneName; //接入方场景名称
        this.dataForm.id = obj.id;
        this.dataForm.manufactorName = obj.manufactorName; //接入方厂家名称
        // this.dataFormPerson.modelId = obj.modelId;
        this.dataForm.manufactorIp = obj.manufactorIp; //接入方IP地址
        this.dataForm.manufactorUse = obj.manufactorUse; //接入方用途
        this.dataForm.manufactorSystem = obj.manufactorSystem; //接入方系统
        this.dataForm.officialPeople = obj.officialPeople; //局方负责人（主数据工号+姓名）
        this.dataForm.manufactorDept = obj.manufactorDept; //局方部门
        this.dataForm.manufactorPeople = obj.manufactorPeople; //厂家负责人（主数据工号+姓名）
        this.dataForm.manufactorApikey = obj.manufactorApikey; //接入方APIKEY
        this.dataForm.remail = obj.remail; //备注
        this.dataForm.examineStatus = obj.examineStatus; //状态
        console.log(
          "this.dataForm.examineStatus=",
          this.dataForm.examineStatus
        );
      }
    },
    //通过
    // handleThrough() {
    //   console.log("-----", this.formInline);
    //   //   return
    //   this.$http({
    //     url: this.$http.adornUrl("/WorkDispatchFormalCommon/getsucess"),
    //     method: "get",
    //     params: this.$http.adornParams({
    //       id: this.formInline.id,
    //     }),
    //   }).then(({ data }) => {
    //     if (data && data.code === 0) {
    //       this.$message({
    //         message: "操作成功",
    //         type: "success",
    //         duration: 1500,
    //         onClose: () => {
    //           this.addorUpdateVisible = false;
    //           this.$emit("getLingNum");
    //         },
    //       });
    //     } else {
    //       this.$message.error(data.msg);
    //     }
    //   });
    // },
    //通过/不通过/提交
    handleThrough(examineStatus) {
      console.log("-----", examineStatus);
    //   return
      this.$http({
        url: this.$http.adornUrl("/cpcpManufactorScene/CmsTwoSucesse"),
        method: "get",
        params: this.$http.adornParams({
          id: this.dataForm.id,
          remail: this.dataForm.remail,
          manufactorApikey:this.dataForm.manufactorApikey,
          examineStatus:examineStatus
        }),
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500,
            onClose: () => {
              this.addorUpdateVisible = false;
              this.$emit("getLingNum");
            },
          });
        } else {
          this.$message.error(data.msg);
        }
      });
    },
  },
  mounted() {},
};
</script>

<style scoped>
.ei_dialog >>> .el-dialog {
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-47%, -40%);
  /* max-height: calc(100% - 200px); */
  max-width: calc(100% - 30px);
}

.ei_dialog >>> .el-dialog .el-dialog__body {
  flex: 1;
  overflow: auto;
}
</style>